package basisApi

import (
	"github.com/Sir-yuChen/funAnalyse/model"
	"github.com/Sir-yuChen/funAnalyse/model/common/response"
	"github.com/Sir-yuChen/funAnalyse/model/request"
	"github.com/Sir-yuChen/funAnalyse/utils"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type StockFilesController struct{}

// GetStockFiles 多条件查询
// @Summary stockFiles get
// @Tags 公共接口
// @Accept application/json
// @Produce application/json
// @Param data body model.StockFilesModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/files/getOneFileInfo [GET]
func (b *StockFilesController) GetStockFiles(c *gin.Context) {
	var req model.StockFilesModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "GetStockFiles", req, c)
		return
	}
	apiReturn := stockFilesService.GetStockFiles(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// UploadFile
// @Summary 文件上传
// @Tags 公共接口
// @Accept application/json
// @Produce application/json
// @Param data body request.UploadFileRequest true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/files/uploadFile [POST]
func (b *StockFilesController) UploadFile(c *gin.Context) {
	var req request.UploadFileRequest
	/*
		invalid character '-' in numeric literal
		 由于使用的form-data 方式带参数 后端不能使用json转换
	*/
	if err := c.ShouldBind(&req); err != nil {
		utils.ErrValidatorResp(err, "uploadFile", req, c)
		return
	}
	apiReturn := stockFilesService.UploadFiles(&req, c)
	response.WithApiReturn(apiReturn, c)
	return
}

// DownloadFile
// @Summary 文件下载
// @Tags 公共接口
// @Accept application/json
// @Produce application/json
// @Param data body request.DownloadFileRequest true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/files/downloadFile [Get]
func (b *StockFilesController) DownloadFile(c *gin.Context) {
	var req request.DownloadFileRequest
	if err := c.ShouldBind(&req); err != nil {
		utils.ErrValidatorResp(err, "downloadFile", req, c)
		return
	}
	apiReturn := stockFilesService.DownloadFile(&req, c)
	response.WithApiReturn(apiReturn, c)
	return
}

// UpdateStockFiles
// @Summary stockFiles update
// @Tags 公共接口
// @Accept application/json
// @Produce application/json
// @Param data body model.StockFilesModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/files/updateFileInfo [POST]
func (b *StockFilesController) UpdateStockFiles(c *gin.Context) {
	var req model.StockFilesModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "UpdateStockFiles", req, c)
		return
	}
	apiReturn := stockFilesService.UpdateStockFiles(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// DelStockFiles
// @Summary stockFiles del
// @Tags 公共接口
// @Accept application/json
// @Produce application/json
// @Param data body model.StockFilesModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/files/delFile [Get]
func (b *StockFilesController) DelStockFiles(c *gin.Context) {
	var req model.StockFilesModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "DelStockFiles", req, c)
		return
	}
	apiReturn := stockFilesService.DelStockFiles(&req)
	response.WithApiReturn(apiReturn, c)
	return
}
